package wang.hu.bos.service.transit.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import wang.hu.bos.dao.transit.InOutStorageInfoDao;
import wang.hu.bos.dao.transit.TransitDao;
import wang.hu.bos.domain.transit.InOutStorageInfo;
import wang.hu.bos.domain.transit.TransitInfo;
import wang.hu.bos.service.transit.InOutStorageInfoService;

@Service
@Transactional
public class InOutStorageInfoServiceImpl implements InOutStorageInfoService {
	@Autowired
	private InOutStorageInfoDao inOutStorageInfoDao;
	@Autowired
	private TransitDao transitDao;

	@Override
	public void save(String transitInfoid, InOutStorageInfo inOutStorageInfo) {
		inOutStorageInfoDao.save(inOutStorageInfo);
		TransitInfo transitInfo = transitDao.findOne(Integer
				.parseInt(transitInfoid));
		transitInfo.getInOutStorageInfos().add(inOutStorageInfo);
		if (inOutStorageInfo.getOperation().equals("到达网点")) {
			transitInfo.setStatus("到达网点");
			transitInfo.setOutletAddress(inOutStorageInfo.getAddress());
		}

	}

}
